<?php

declare(strict_types=1);

namespace App\Controller;

use App\Service\PageService\ChannelPS;
use Hyperf\Di\Annotation\Inject;
use App\Request\ChannelRequest;

class ChannelController extends AbstractController
{
    /**
     * @Inject
     * @var ChannelPS
     */
    protected $ps;

    /**
     * 渠道列表
     *
     * @param ChannelRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function list(ChannelRequest $request)
    {
        $data = $request->validated();

        $loginUserInfo = $this->getLoginUserInfo();

        $page = (int)($data['page'] ?? DEFAULT_PAGE);
        $size = (int)($data['size'] ?? DEFAULT_PAGE_SIZE);

        $res = $this->ps->list($loginUserInfo, $data, $page, $size);

        return $this->response->success($res);
    }

}
